/*
 * 一个简单的插件在启动该插件时启动插件的activity
 *
**/
package com.apkplug.imtheme;
import java.util.Dictionary;
import java.util.Hashtable;

import org.apkplug.Bundle.ApkplugTheme;
import org.apkplug.Bundle.OSGIServiceAgent;
import org.apkplug.Bundle.ThemeControl;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;

import android.content.Intent;
public class SimpleBundle implements BundleActivator
{
    private BundleContext mcontext = null;
    public void start(BundleContext context) 
    {
        System.err.println("你好我是插件,我将为你展示启动acitivty我已经启动了 我的BundleId为："+context.getBundle().getBundleId());
        this.mcontext = context;
        //将BundleContext放入BundleContextFactory工厂中
        //方便插件的其他类里面调用
        OSGIServiceAgent<ThemeControl> agent=new OSGIServiceAgent<ThemeControl>(mcontext,ThemeControl.class);
        try {
        	Dictionary<String,Object> properties =new Hashtable<String,Object>();
        	properties.put("serviceName", "mystyle");
			agent.getService().addStyles(mcontext, ApkplugTheme.class.getCanonicalName(), 
					new chatstylesImp(),properties); 
			//设置apkplug层主题
			agent.getService().setTheme(mcontext, mcontext.getBundle(),R.style.AppTheme_Default);
		} catch (Exception e) {
			// TODO 自动生成的 catch 块
			e.printStackTrace();
		}
        
        BundleContextFactory.getInstance().setBundleContext(context);
        BundleContextFactory.getInstance().setBundleContext(context);
    }
   
    public void stop(BundleContext context)
    {
    	System.err.println("你好我是插件,我被停止了 我的BundleId为："+context.getBundle().getBundleId());
      
    }
	
}
